package com.exercises;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Exercise12 {


    public String intToRoman(int num) {
        int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
        String[] rom = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};

        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < values.length; i++) {
            int count = num % values[i];
            String roman = rom[i];
            for (int j = 0; j < count; j++) {
                buffer.append(roman);
            }
        }
        return buffer.toString();
    }
}
